<template>
  <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="auto">
    <el-form-item label="地址简写" prop="name">
      <el-input
        v-model.trim="ruleForm.name"
        placeholder="请输入地名名称(例如:浙江)"
      ></el-input>
    </el-form-item>
    <el-form-item label="地址全称" prop="extName">
      <el-input
        v-model.trim="ruleForm.extName"
        placeholder="请输入地名名称(例如:浙江省)"
      ></el-input>
    </el-form-item>
  </el-form>
</template>

<script>
export default {
  data() {
    return {
      ruleForm: {
        name: "",
        extName: "",
        id: 0
      },
      rules: {
        extName: [
          { required: true, message: "请输入地名名称", trigger: "blur" }
        ],
        name: [{ required: true, message: "请输入地名名称", trigger: "blur" }]
      }
    };
  },
  methods: {
    submitForm(formName = "ruleForm") {
      this.$refs[formName].validate(valid => {
        if (valid) {
          this.$emit("submit", this.ruleForm);
        } else {
          return false;
        }
      });
    }
  }
};
</script>

<style lang="scss" scoped></style>
